package com.common.android.utils.concurrent;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;

public class DuplicateCheckNdThreadPoolExecutor extends NdThreadPoolExecutor {

	public DuplicateCheckNdThreadPoolExecutor(int corePoolSize,
			int maximumPoolSize, long keepAliveTime, TimeUnit unit,
			BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory) {
		super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,
				threadFactory);
	}

	@Override
	public void execute(Runnable command) {
		if (command == null) {
			return;
		}
		
		String className = command.getClass().getName();
		for (NdAbstractTask task : mQueueTask) {
			if (className.equals(task.getClass().getName())) { // 如果有重复的任务在线程池中，将不予以执行
				return;
			}
		}
		super.execute(command);
	}
	
	

}
